﻿//获取历史消息
var productpage = 0;
var productlistpagecount = 1;
var pageSize1 = 3;
var isjz=0;//是否加载完成
var img = $("#progressImgage");
var mask = $("#maskOfProgressImage");
var isjzrm=0;//热门是否加载完成
var iTotalDisplayRecords ;//总量
function get_product() {

	$
			.ajax({
				url : _path + "/member/myordersLoadMore?pageNo="
						+ productpage + "&pageSize=" + pageSize1,
				type : "get",
				dataType : "json",
				async : false,
				error : function(request) {
					alert("连接错误！");
				},	
				complete: function(XMLHttpRequest, textStatus) {
					 img = $("#progressImgage");
					 mask = $("#maskOfProgressImage");
					img.hide();//隐藏加载图片
					mask.hide(); //隐藏加载图片
					},
				success : function(jsonMap) {
			
					var list = jsonMap.datalist;
					 iTotalDisplayRecords = jsonMap.iTotalDisplayRecords;
					if (list.length > 0) {
						for (var i = 0; i < list.length; i++) {
							var data = list[i];
							var msgContent='';
					  
							msgContent = " <div class='myorder'>"+
		                    "	 <div class='order-title'>" +
		                    "	  <span class='left'>   "+data.productxname+" </span> " +
		                    "	 <span style='float: right;'>" +
		                    "	 "+data.createTime+"" +
		                    "	       </span>" +
							  "	    </div>" +
							  "	      <div class='order-card'>" +
							  "	              <img src=' "+data.imgUrl+" ' alt=''>" +
							  "	       <div class='order-card-right'> " +
							//	"		  <p>奖励：获得积分+1%</p>" +
							  //	  "	         <p>预期总奖励积分"+data.yjjf.toFixed(2)+"</p>" +
						//	  "	             <p>已获得***奖励积分</p>   " +
							  "	                        </div>" +
							  "	     </div>" +
							  "	      <div class='order-detail'>" +
							 "	         <p> 天数:<span>"+data.rzts+"</span>份 共计：<span>"+data.total+"</span>元</p>|  " +resr(data.isfb) +
					//		  "	        </div> " +opengune(data.sendStatus,data.id)+
							  "	        </div> " +
							 "	  </div>" ;
							
						
							        $("#mydan").append(msgContent);
						 
						
						}
					}
					// 分页
					var count = productlistpagecount * 3;
					if (count >= iTotalDisplayRecords) {
						isjz=1;
						$("#productlistload")
								.html(
										"<div class='bl_more'><span id='spancolor'>已全部加载完</span></div>");
					}  
				}
			});
}

function opengune(po,id){
	if(po!=4){
		return	"<input type='button' id="+id+" value='托管转租'  onclick='zhezke("+id+")'>" ;
	}else{
		return	'';
	}
	  
}
function resr(po){
	if(po==0){
		return	'可提前入住';
	}else{
		return	'不可提前入住';
	}
	  
}
// 下一页
function listpageNext() {
 
		productlistpagecount++;
		productpage = productpage + 3;
		get_product();
 

}



function zhezke(id){

	 $.ajax({
         url: _path + "/member/checkzhuanz?id="+id,
         type: "get",
         async: false,
         dataType: 'json',
         success: function (data) {
      	   if(data.statusCode==200){
					layer.open({ content:"转租成功",skin: 'msg' ,time: 2 });//2秒后自动关闭
					$("#"+id).attr("value","转租成功");
					$("#"+id).attr('disabled',"true");
                    
      	   }else{
		    			layer.open({ content:data.info,skin: 'msg' ,time: 2 });//2秒后自动关闭
		          
      	   }
         }
   });
}


function get_producthide(){
	
	productpage = 0;
		pageSize1 = 3;
	get_product();
}

$(function(){
	get_producthide();
$(window).scroll(function(){
	var scrollTop = $(window).scrollTop();
	var scrollHeight = document.body.scrollHeight;
	var windowHeight = document.documentElement.clientHeight;

	if (scrollTop + windowHeight >= scrollHeight) {
			//此处是滚动条到底部时候触发的事件，在这里写要加载的数据，或者是拉动滚动条的操作
		//	page = parseInt(page) + 1;//页数
		
			img.show().css({
				"position": "fixed",
				"top": "45%",
				"left": "40%",
				"margin-top": function () { return -1 * img.height() / 2; },
				"margin-left": function () { return -1 * img.width() / 2; }
			});//正在加载图标
				    	if(isjz!=1){
				    		listpageNext();
						}else{
							 $("#progressImgage").hide();//隐藏加载图片
							 $("#maskOfProgressImage").hide(); //隐藏加载图片
						}
		 
			
		
			
		
			
	}
});
});